package com.manong.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manong.dao.LeaveMapper;
import com.manong.dao.ShopMapper;
import com.manong.entity.Leave;
import com.manong.entity.Shop;
import com.manong.service.LeaveService;
import com.manong.service.ShopService;
import com.manong.vo.LeaveVo;
import org.springframework.stereotype.Service;

@Service
public class LeaveServiceImpl extends ServiceImpl<LeaveMapper, Leave> implements LeaveService {
    @Override
    public IPage<Leave> findLeaveListByUsername(IPage<Leave> page, LeaveVo leaveVo) {
        QueryWrapper<Leave> queryWrapper = new QueryWrapper<Leave>();
        queryWrapper.eq(!ObjectUtils.isEmpty(leaveVo.getStatus()),"status",leaveVo.getStatus())
                .eq(!ObjectUtils.isEmpty(leaveVo.getUsername()),"username",leaveVo.getUsername());
        return baseMapper.selectPage(page,queryWrapper);
    }

    @Override
    public boolean deleteById(Long id) {
        return baseMapper.deleteById(id)>0;
    }

    @Override
    public IPage<Leave> findLeaveListAllByUsername(IPage<Leave> page, LeaveVo leaveVo) {
        QueryWrapper<Leave> queryWrapper = new QueryWrapper<Leave>();
        queryWrapper.eq(!ObjectUtils.isEmpty(leaveVo.getStatus()),"status",leaveVo.getStatus());
        return baseMapper.selectPage(page,queryWrapper);
    }
}
